import { getConnectionState } from './plugin'
// 04：手环 02：体脂秤 08：血压计 06：血糖仪 
// 体重秤("01"),
// 体重脂肪测量仪("02"),
// 手环("04"),
// 血糖仪("06"),
// 血压计("08"),
// 人体成分分析仪("09"),
// 支付卡("11"),
// pillow("14"),
// NCP_DETECT_DEVICE("15"), //新冠检测设备
// 跳绳("16"),
// 药盒("17"),
// 哑铃("18");
const iconMap = {
  // 手环
  "04": {
     connected: 'https://pics.leshiguang.com/vpage/2024/01/22/d7eb1d2b93ca4807b4befea262f9030e.png',
     disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/bb52823eb9d94bf69d1638221a4117f2.png',
  },

  // 手表
  "2": {
    connected: 'https://pics.leshiguang.com/vpage/2024/01/22/0089a25c72954fecb50bdf2f4ba26e76.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/e293aa8e83934efcae44270f07fbc972.png',
  },
  
  // 体脂称
  "01": {
    connected: 'https://pics.leshiguang.com/vpage/2024/01/22/c0d482d89ba941f68688a8ebfadba526.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/e4a2849ac2bf4de599d1b97b7bb1c8b4.png',
  },
  "02": {
    connected : 'https://pics.leshiguang.com/vpage/2024/01/22/c0d482d89ba941f68688a8ebfadba526.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/e4a2849ac2bf4de599d1b97b7bb1c8b4.png',
  },
  // 跳绳
  "16": {
    connected: 'https://pics.leshiguang.com/vpage/2024/01/22/3527150cf91f4018aa2062754bb0d05e.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/ae15d31658654b789eeb3655f3648dde.png',
  },

  // 血糖仪
  "06": {
    connected : 'https://pics.leshiguang.com/vpage/2024/01/22/be0a346cdf4d4e6d8b9f6791c7b3dbd6.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/f23d95b33c984463a2d26b31d7ee3dc1.png',
  },

  // 药盒
  "17": {
    connected: 'https://pics.leshiguang.com/vpage/2024/01/22/f8d9e37b93a44d9dbeb0faf764fcea28.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/94f8ec4e02934f3d8b5cc592faaca18a.png',
  },

  // 血压计
  "08": {
    connected : 'https://pics.leshiguang.com/vpage/2024/01/22/b22033b2cc454ff48c3e62cd3472c648.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/a12a87462cfc4fbdad36c0d1e2a1e07a.png',
  },

  // 哑铃
  "18": {
    connected: 'https://pics.leshiguang.com/vpage/2024/01/22/76b3819a31d24386a52c3629f17f6e97.png',
    disconnect: 'https://pics.leshiguang.com/vpage/2024/01/22/bb739771196f40d5ae464abb659fddb0.png',
  },
}

export const getDeviceIcon = (device) => {
  if (!device) return '';

  const item = iconMap[device.productTypeCode];
  if (!item) return '';

  const state = getConnectionState(device.mac);
  if (state === 3 || state === 4) {
    return item.connected;
  } else {
    return item.disconnect;
  }
}